<?php
/**
 * Created by IntelliJ IDEA.
 * User: jimmyhsu
 * Date: 2017/3/30
 * Time: 15:13
 */
$real_name = "unknown";
session_start();
if (!empty($_SESSION['username']) && !empty($_SESSION['password'])) {
    $username = $_SESSION['username'];
    $password = $_SESSION['password'];
    include('db/conn.php');
    $sql = "select * from teacher where t_id='$username' and password='$password'";
    $result = mysqli_query($cn, $sql);
    if (mysqli_num_rows($result) > 0) {
        $real_name = mysqli_fetch_array($result)[1];
    } else {
        session_unset();
        session_destroy();
        echo "<script>location.href='login.php';</script>";
    }
} else {
    echo "<script>location.href='redirect.php';</script>";
}